//
//  XXTGTChooseAddressableViewCell.m
//  XiuXiuTuanGou
//
//  Created by 张敬 on 2018/7/10.
//  Copyright © 2018年 XiuXiuTuanGou. All rights reserved.
//

#import "XXTGChooseAddressTableViewCell.h"

@interface XXTGChooseAddressTableViewCell()

@property (nonatomic, strong) UIImageView *circle; //

@end

@implementation XXTGChooseAddressTableViewCell

//MARK: - LifeCycle Methods
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self initParams];
    }
    return self;
}

- (void)initParams
{
    
    [self addSubview:self.addressLabel];
    [self addSubview:self.detailAddressLabel];
    [self addSubview:self.distanceLabel];
    
    [self addSubview:self.circle];
    [self addSubview:self.lineView];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    __weak typeof(self) weakself = self;
    
    [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(weakself.mas_left).offset(20);
        make.top.equalTo(weakself.mas_top).offset(15);
        make.height.mas_equalTo(22);
        make.right.mas_equalTo(weakself.mas_right).offset(-115);
//        make.width.mas_equalTo(self.mas_width).offset(-115);
    }];
    
    [_detailAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(weakself.mas_left).offset(20);
        make.top.equalTo(weakself.addressLabel.mas_bottom).offset(4);
        make.height.mas_equalTo(20);
        make.right.mas_equalTo(weakself.mas_right).offset(-32);
//        make.width.mas_equalTo(self.mas_width).offset(-32);
    }];
    
    [_distanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(80);
        make.top.equalTo(weakself.addressLabel.mas_top);
        make.right.equalTo(weakself.mas_right).offset(-32);
    }];
    
    
    [_circle mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.height.width.mas_equalTo(11);
        make.top.equalTo(weakself.mas_top).offset(28);
        make.right.equalTo(weakself.mas_right).offset(-20);
    }];
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself);
        make.right.mas_equalTo(weakself);
        make.height.mas_equalTo(0.5);
        make.bottom.mas_equalTo(weakself);
    }];
}

- (void)updataWith:(NSDictionary *)dict
{
    self.addressLabel.text = dict[@"title"];
    self.detailAddressLabel.text = dict[@"address"];
//    if ([kUserDefaults objectForKey:kLocationLatitudeKey] && [kUserDefaults objectForKey:kLocationLongitudeKey]) {
//        self.distanceLabel.text = [NSString stringWithFormat:@"%@km",[dict[@"distance"] stringValue]];
//    }
}


//MARK: - Setter and Getter Methods
- (UILabel *)addressLabel
{
    if (!_addressLabel) {
        
        _addressLabel = [[UILabel alloc] init];
        _addressLabel.textColor = KBlackColor;
        _addressLabel.font = mBlodFont(16);;
        
    }
    return _addressLabel;
}

- (UILabel *)detailAddressLabel
{
    if (!_detailAddressLabel) {
        
        _detailAddressLabel = [[UILabel alloc] init];
        _detailAddressLabel.textColor = RGB(153, 153, 153);
        _detailAddressLabel.font = mFont(14);
        
    }
    return _detailAddressLabel;
}

- (UILabel *)distanceLabel
{
    if (!_distanceLabel) {
        
        _distanceLabel = [[UILabel alloc] init];
        _distanceLabel.textColor = RGB(153, 153, 153);
        _distanceLabel.font = mFont(14);
    }
    return _distanceLabel;
}

- (UIImageView *)circle
{
    if (!_circle) {
        
        _circle = [[UIImageView alloc] init];
        _circle.image = [UIImage imageNamed:@"choose"];
    }
    return _circle;
}

- (UIView *)lineView
{
    if (!_lineView) {
        _lineView = [[UIView alloc]init];
      //  _lineView.backgroundColor = xxtg_lineColor_gray;//
    }
    return _lineView;
}


@end
